package com.frejoys.admin.controller;

import com.frejoys.common.aop.Authority;
import com.frejoys.common.aop.Authorization;
import com.frejoys.common.constant.CommonConstant;
import com.frejoys.common.dto.admin.AdminStoreEnterUpdateStatusDto;
import com.frejoys.common.dto.admin.SetEnterAgentDto;
import com.frejoys.common.dto.admin.StoreEnterStatusDto;
import com.frejoys.common.dto.admin.UpdateAgentDto;
import com.frejoys.common.dto.common.PageDto;
import com.frejoys.common.response.Result;
import com.frejoys.common.vo.admin.UserAgentVo;
import com.frejoys.common.vo.app.StoreEnterDetailsVo;
import com.frejoys.service.StoreEnterService;
import com.frejoys.service.UserService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Tag(name = "商家入驻", description = "商家入驻")
@RestController
@RequiredArgsConstructor
@RequestMapping(CommonConstant.routePrefixAdmin)
@Authorization(Authority.Private)
public class AdminStoreEnterController {

    private final StoreEnterService storeEnterService;

    private final UserService userService;


    @PostMapping("/adminStoreEnter/updateAgent")
    @Operation(summary = "添加代理人")
    public Result updateAgent(@RequestBody @Validated UpdateAgentDto dto){
        //校验代理人
        userService.verifyAgentUserId(dto.getAgentUserId());
        return Result.success(storeEnterService.updateAgent(dto));
    }

    @PostMapping("/adminStoreEnter/setEnterAgent")
    @Operation(summary = "修改代理人")
    public Result setEnterAgent(@RequestBody @Validated SetEnterAgentDto dto){
        //校验代理人
        userService.verifyAgentUserId(dto.getAgentUserId());
        return Result.success(storeEnterService.setEnterAgent(dto));
    }
}
